//
//  Head.m
//  HYHOME
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "Head.h"
#import "SpeakModel.h"
#import "UIImageView+WebCache.h"



@implementation Head

-(void)dealloc{

    [self.icon_url release];
    [self.name release];
    [super dealloc];

}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubView];
        
    
    }

    return self;


}

- (void)createSubView{

    self.name = [[UILabel alloc]init];
    
    self.name.font = [UIFont boldSystemFontOfSize:17];
    [self.contentView addSubview:self.name];
    
    
    self.icon_url = [[UIImageView alloc]init];
    [self.contentView addSubview:self.icon_url];
 
    

    [self.name release];
    [self.icon_url release];

}


- (void)layoutSubviews{
    
    [super layoutSubviews];
    self.icon_url.frame = CGRectMake(30.f, 30.f, 60.f, 60.f);
    self.icon_url.layer.masksToBounds = YES;
    self.icon_url.layer.cornerRadius = 30;
    self.name.frame = CGRectMake(120, 50, 150, 30);
    
}

+ (CGFloat)heightForLabel:(NSString *)text{
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 40, 0) options: NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];
    return rect.size.height;
}

+ (CGFloat)heightForCell:(SpeakModel *)model{

  return 100;


    
}


- (void)passModel:(SpeakModel *)model{
    
    [self.icon_url sd_setImageWithURL:[NSURL URLWithString:model.icon_url] placeholderImage:[UIImage imageNamed:@"me"]];
    self.name.text = model.name;
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
